Skip to content

[ci] DEBUG: run macOS arm64 cppia JIT under lldb (do not merge) - #13105

Closed
Simn wants to merge 5 commits into
developmentfrom
claude/trusting-curie-jjo6ag
Closed

Simn wants to merge 5 commits into
developmentfrom
claude/trusting-curie-jjo6ag

Conversation

@Simn

@Simn Simn commented Oct 31, 2026

Copy link
Copy Markdown
Member

Diagnostic-only PR, not meant to be merged. It tries to get a native backtrace for the intermittent mac-test (cpp, arm64) failures.

Background

About 1 in 3 mac-test (cpp, arm64) jobs fail. Every failure shows the same thing: the interpreted Host-debug bin/unit.cppia run passes, then the -jit run dies with:

Called from cpp.cppia.Host::runFile cpp/cppia/Host.hx line 45
Error : hxSehException

Host.hx:45 is Module.fromData(...), so the crash happens while the module is being JIT-compiled (CppiaModule::compile), before any script code runs. hxSehException is hxcpp's HXCPP_CATCH_SEGV handler converting a SIGSEGV. The failures predate the hxcpp sljit upgrade (HaxeFoundation/hxcpp#1434) and only show up on macOS arm64.

Changes

  • tests/runci/targets/Cpp.hx: on macOS arm64, run the unit cppia JIT up to 30 times under lldb --batch before the normal cppia runs. lldb stops on the EXC_BAD_ACCESS before hxcpp's handler sees it. On a crash the job prints all thread backtraces, registers, the symbol at $pc, disassembly and the loaded images, then fails.
  • .github/workflows/main.yml: disable the Windows and Linux builds, which skips all of their dependent jobs. Reduce mac-test to cppia on arm64 only. Run DevToolsSecurity -enable so lldb can attach. The macOS x86_64 build still runs because the universal binary needs it.

Generated by Claude Code

Diagnostic-only change to capture a native backtrace for the intermittent
hxSehException crash of the cppia JIT on macOS arm64, which happens while
the unit test module is being JIT-compiled (Host.hx line 45).

- Run the cppia JIT unit test up to 30 times under lldb on macOS arm64,
  dumping backtraces, registers and disassembly when it crashes.
- Disable all other CI jobs so only mac-test (cppia, arm64) runs.

Not intended to be merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Va4FXG8Zex7iQytzPnDKyg
The crash did not reproduce in 30 runs under lldb, which disables ASLR by
default, while the following plain run crashed immediately. Re-enable ASLR
and print the first run's lldb output to confirm the setting is applied.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Va4FXG8Zex7iQytzPnDKyg
The crash was caught in ScriptCallable::compile at CppiaFunction.cpp:662
with body == 0x500000000, which looks like a use-after-free or an
overwrite. Run a few times with Guard Malloc first to make the bad access
fault where it happens, then loop with MallocScribble and stack logging,
and dump the ScriptCallable/CppiaFunction and its malloc history on crash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Va4FXG8Zex7iQytzPnDKyg
@tobil4sk

Copy link
Copy Markdown
Member

Interesting 👀 We might also be able to get some information here about which part is being compiled when the error happens: https://github.com/HaxeFoundation/hxcpp/blame/c9892dc11b0a7ab1f5960f656faea89222c2d682/src/hx/cppia/Cppia.h#L47

The cppia generator emitted a bare RETURN expression as the body of an
abstract method. hxcpp reads every class method as a ScriptCallable, and
when JIT compiling it calls the non-virtual ScriptCallable::compile on it,
which reads past the end of the much smaller RetVal object. Depending on
the heap layout, this crashed while loading the module (seen on macOS
arm64 with Issue11666's abstract Foo.foo).

Reuse the no-op tfunc that the C++ generator already builds for abstract
methods, so cppia gets a proper FUN with the right args and defaults.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Va4FXG8Zex7iQytzPnDKyg
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Va4FXG8Zex7iQytzPnDKyg

Simn commented Oct 31, 2026

Copy link
Copy Markdown
Member Author

Closing this debugging PR. Guard Malloc found the root cause (abstract methods emitted as a bare RETURN, not a FUN), and the fix is in #13106 without the CI diagnostics.


Generated by Claude Code

@Simn Simn closed this Oct 31, 2026
@Simn
Simn deleted the claude/trusting-curie-jjo6ag branch November 1, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants